package com.example.myview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;

import com.example.bean.CrossBean;
import com.example.utils.ColorUtil;
import com.example.utils.GridUtils;
import com.example.utils.LineUtil;


/**背景 view
 * Created by Arvin on 2016/10/26.
 */
public class BackView extends View implements ChartConstant{
    //时间左上Y坐标
    protected float timeStartY;
    //总高
    protected float mHeight;
    //总宽
    protected float mWidth;
    //指标高度
    protected float indexH;
    //指标左上y坐标
    protected float indexStartY;
    //分时图,K线高度
    protected float mainH;
    public BackView(Context context, AttributeSet attrs) {
        super(context, attrs);


    }


    private void initWidthAndHeight() {

        mHeight = getHeight();
        mWidth = getMeasuredWidth();
        mainH = mHeight * MAIN_SCALE;
        indexH = mHeight * INDEX_SCALE;
        indexStartY = mHeight - indexH;
        timeStartY = indexStartY - mHeight * TIME_SCALE;

    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        initWidthAndHeight();
        GridUtils.drawGrid(this,canvas, mWidth, mainH);
        GridUtils.drawIndexGrid(this,canvas, indexStartY, mWidth, indexH);

    }

    /**
     * 画分时线的十字线
     */
    public void drawLine()
    {
        postInvalidate();

    }

}
